/**
 * HTTP 状态码常量
 */
export const HTTP_STATUS = {
  // 成功状态码
  OK: 200,
  CREATED: 201,
  ACCEPTED: 202,
  NO_CONTENT: 204,

  // 重定向状态码
  MOVED_PERMANENTLY: 301,
  FOUND: 302,
  NOT_MODIFIED: 304,

  // 客户端错误状态码
  BAD_REQUEST: 400,
  UNAUTHORIZED: 401,
  FORBIDDEN: 403,
  NOT_FOUND: 404,
  METHOD_NOT_ALLOWED: 405,
  CONFLICT: 409,
  UNPROCESSABLE_ENTITY: 422,
  TOO_MANY_REQUESTS: 429,

  // 服务器错误状态码
  INTERNAL_SERVER_ERROR: 500,
  NOT_IMPLEMENTED: 501,
  BAD_GATEWAY: 502,
  SERVICE_UNAVAILABLE: 503,
  GATEWAY_TIMEOUT: 504,
} as const;

/**
 * 用户角色常量
 */
export const USER_ROLES = {
  ADMIN: 'admin',
  USER: 'user',
  MODERATOR: 'moderator',
  GUEST: 'guest',
} as const;

/**
 * 用户状态常量
 */
export const USER_STATUS = {
  ACTIVE: 'active',
  INACTIVE: 'inactive',
  SUSPENDED: 'suspended',
  PENDING: 'pending',
  DELETED: 'deleted',
} as const;

/**
 * 订单状态常量
 */
export const ORDER_STATUS = {
  PENDING: 'pending',
  CONFIRMED: 'confirmed',
  PROCESSING: 'processing',
  SHIPPED: 'shipped',
  DELIVERED: 'delivered',
  CANCELLED: 'cancelled',
  REFUNDED: 'refunded',
} as const;

/**
 * 支付状态常量
 */
export const PAYMENT_STATUS = {
  PENDING: 'pending',
  PROCESSING: 'processing',
  COMPLETED: 'completed',
  FAILED: 'failed',
  CANCELLED: 'cancelled',
  REFUNDED: 'refunded',
} as const;

/**
 * 支付方式常量
 */
export const PAYMENT_METHODS = {
  CREDIT_CARD: 'credit_card',
  DEBIT_CARD: 'debit_card',
  PAYPAL: 'paypal',
  ALIPAY: 'alipay',
  WECHAT_PAY: 'wechat_pay',
  BANK_TRANSFER: 'bank_transfer',
  CASH: 'cash',
} as const;

/**
 * 验证码类型常量
 */
export const VERIFICATION_CODE_TYPES = {
  EMAIL_VERIFICATION: 'email_verification',
  PASSWORD_RESET: 'password_reset',
  TWO_FACTOR_AUTH: 'two_factor_auth',
  PHONE_VERIFICATION: 'phone_verification',
} as const;

/**
 * 文件上传类型常量
 */
export const UPLOAD_TYPES = {
  IMAGE: 'image',
  VIDEO: 'video',
  AUDIO: 'audio',
  DOCUMENT: 'document',
  ARCHIVE: 'archive',
  OTHER: 'other',
} as const;

/**
 * 文件大小限制常量（字节）
 */
export const FILE_SIZE_LIMITS = {
  IMAGE: 5 * 1024 * 1024, // 5MB
  VIDEO: 100 * 1024 * 1024, // 100MB
  AUDIO: 10 * 1024 * 1024, // 10MB
  DOCUMENT: 10 * 1024 * 1024, // 10MB
  ARCHIVE: 50 * 1024 * 1024, // 50MB
  DEFAULT: 1 * 1024 * 1024, // 1MB
} as const;

/**
 * 支持的图片格式常量
 */
export const SUPPORTED_IMAGE_FORMATS = [
  'jpeg',
  'jpg',
  'png',
  'gif',
  'webp',
  'svg',
  'bmp',
] as const;

/**
 * 支持的视频格式常量
 */
export const SUPPORTED_VIDEO_FORMATS = [
  'mp4',
  'avi',
  'mov',
  'wmv',
  'flv',
  'webm',
  'mkv',
] as const;

/**
 * 支持的音频格式常量
 */
export const SUPPORTED_AUDIO_FORMATS = [
  'mp3',
  'wav',
  'flac',
  'aac',
  'ogg',
  'wma',
] as const;

/**
 * 支持的文档格式常量
 */
export const SUPPORTED_DOCUMENT_FORMATS = [
  'pdf',
  'doc',
  'docx',
  'xls',
  'xlsx',
  'ppt',
  'pptx',
  'txt',
  'rtf',
] as const;

/**
 * 缓存键前缀常量
 */
export const CACHE_KEYS = {
  USER: 'user:',
  SESSION: 'session:',
  VERIFICATION_CODE: 'verification:',
  RATE_LIMIT: 'rate_limit:',
  API_RESPONSE: 'api_response:',
  TEMP_DATA: 'temp:',
} as const;

/**
 * 缓存过期时间常量（秒）
 */
export const CACHE_EXPIRY = {
  MINUTE: 60,
  FIVE_MINUTES: 5 * 60,
  TEN_MINUTES: 10 * 60,
  THIRTY_MINUTES: 30 * 60,
  HOUR: 60 * 60,
  SIX_HOURS: 6 * 60 * 60,
  TWELVE_HOURS: 12 * 60 * 60,
  DAY: 24 * 60 * 60,
  WEEK: 7 * 24 * 60 * 60,
  MONTH: 30 * 24 * 60 * 60,
} as const;

/**
 * 正则表达式常量
 */
export const REGEX_PATTERNS = {
  EMAIL: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
  PHONE: /^(\+\d{1,3}[- ]?)?\d{10,14}$/,
  PASSWORD: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/,
  URL: /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$/,
  USERNAME: /^[a-zA-Z0-9_]{3,20}$/,
  CHINESE_PHONE: /^1[3-9]\d{9}$/,
  ID_CARD: /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,
  UUID: /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,
} as const;

/**
 * 默认分页参数常量
 */
export const PAGINATION = {
  DEFAULT_PAGE: 1,
  DEFAULT_LIMIT: 10,
  MAX_LIMIT: 100,
  MIN_LIMIT: 1,
} as const;

/**
 * 日期格式常量
 */
export const DATE_FORMATS = {
  DATE: 'YYYY-MM-DD',
  DATETIME: 'YYYY-MM-DD HH:mm:ss',
  TIME: 'HH:mm:ss',
  ISO: 'YYYY-MM-DDTHH:mm:ss.sssZ',
  DISPLAY: 'YYYY年MM月DD日',
  DISPLAY_DATETIME: 'YYYY年MM月DD日 HH:mm:ss',
} as const;

/**
 * API 版本常量
 */
export const API_VERSIONS = {
  V1: 'v1',
  V2: 'v2',
  CURRENT: 'v1',
} as const;

/**
 * 环境常量
 */
export const ENVIRONMENTS = {
  DEVELOPMENT: 'development',
  TESTING: 'test',
  STAGING: 'staging',
  PRODUCTION: 'production',
} as const;

/**
 * 错误消息常量
 */
export const ERROR_MESSAGES = {
  VALIDATION_FAILED: '参数验证失败',
  UNAUTHORIZED: '未授权访问',
  FORBIDDEN: '权限不足',
  NOT_FOUND: '资源不存在',
  CONFLICT: '资源冲突',
  INTERNAL_ERROR: '服务器内部错误',
  RATE_LIMITED: '请求过于频繁',
  INVALID_TOKEN: '无效的令牌',
  TOKEN_EXPIRED: '令牌已过期',
  EMAIL_ALREADY_EXISTS: '邮箱已存在',
  USER_NOT_FOUND: '用户不存在',
  INVALID_CREDENTIALS: '用户名或密码错误',
  ACCOUNT_SUSPENDED: '账户已被暂停',
  FILE_TOO_LARGE: '文件大小超出限制',
  UNSUPPORTED_FILE_TYPE: '不支持的文件类型',
} as const;

/**
 * 成功消息常量
 */
export const SUCCESS_MESSAGES = {
  CREATED: '创建成功',
  UPDATED: '更新成功',
  DELETED: '删除成功',
  LOGIN_SUCCESS: '登录成功',
  LOGOUT_SUCCESS: '退出成功',
  PASSWORD_CHANGED: '密码修改成功',
  EMAIL_SENT: '邮件发送成功',
  VERIFICATION_SUCCESS: '验证成功',
  UPLOAD_SUCCESS: '上传成功',
  OPERATION_SUCCESS: '操作成功',
} as const;